﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dotnet.Code.Extend
{
    public static partial class Ext
    {
        public static void AddOne<T1, T2>(this Dictionary<T1, T2> dict,T1 key,T2 val)
        {
            if (!dict.ContainsKey(key))
            {
                dict.Add(key, val);
            }
            else
            {
                dict.Remove(key);
            }
        }

        public static bool AddKey<T1, T2>(this Dictionary<T1, T2> dict, T1 key, T2 val)
        {
            if (!dict.ContainsKey(key))
            {
                dict.Add(key, val);
                return true;
            }
            return false;
        }

        public static string PrintKey<T1,T2>(this Dictionary<T1,T2> dict)
        {
            string keys = "";
            foreach(KeyValuePair<T1,T2> kp in dict)
            {
                keys += kp.Key + ",";
            }
            return keys;
        }
    }
}
